#include "StdAfx.h"
#include "Interaction.h"
#include <fstream>


CInteraction::CInteraction(void)
{
	char str[1024];
	CString str2;

	std::ifstream fin("talk1.txt");
	while(fin.getline(str,1024)) 
	{
		str2 = str;
		m_strTalkList1.AddTail(str2);
	}
	fin.close();
	
	std::ifstream fin2("talk2.txt");
	while(fin2.getline(str,1024)) 
	{
		str2 = str;
		m_strTalkList2.AddTail(str2);
	}
	fin2.close();

	std::ifstream fin3("talk3.txt");
	while(fin3.getline(str,1024)) 
	{
		str2 = str;
		m_strTalkList3.AddTail(str2);
	}
	fin3.close();

	std::ifstream fin4("talk4.txt");
	while(fin4.getline(str,1024)) 
	{
		str2=str;
		m_strTalkList4.AddTail(str2);
	}
	fin4.close();

	std::ifstream fin5("talk5.txt");
	while(fin5.getline(str,1024)) 
	{
		str2=str;
		m_strTalkList5.AddTail(str2);
	}
	fin5.close();

	
}

CInteraction::~CInteraction(void)
{
}

void CInteraction::Lv0(CString & str)
{
	str = "@#^%@^@#%@#$@#$@#$";	
}

void CInteraction::Lv1(CString & str)
{
	int num = rand()%m_strTalkList1.GetCount();
	POSITION pos = m_strTalkList1.FindIndex(num);
	str = m_strTalkList1.GetAt(pos);
}

void CInteraction::Lv2(CString & str)
{
	int num = rand()%m_strTalkList2.GetCount();
	POSITION pos = m_strTalkList2.FindIndex(num);
	str = m_strTalkList2.GetAt(pos);
}

void CInteraction::Lv3(CString & str)
{
	int num = rand()%m_strTalkList3.GetCount();
	POSITION pos = m_strTalkList3.FindIndex(num);
	str = m_strTalkList3.GetAt(pos);
}

void CInteraction::Lv4(CString & str)
{
	int num = rand()%m_strTalkList4.GetCount();
	POSITION pos = m_strTalkList4.FindIndex(num);
	str = m_strTalkList4.GetAt(pos);
}

void CInteraction::Lv5(CString & str)
{
	int num = rand()%m_strTalkList5.GetCount();
	POSITION pos = m_strTalkList5.FindIndex(num);
	str = m_strTalkList5.GetAt(pos);
}


void CInteraction::Play(int Level, CString & str)
{
	switch(Level/10+1)
	{
	case 0: Lv0(str); break;
	case 1: Lv1(str); break;
	case 2: Lv2(str); break;
	case 3: Lv3(str); break;
	case 4: Lv4(str); break;
	case 5: Lv5(str); break;
	}
}
